<?php

/**
 * Class representation of the HTML <input type="submit" /> tag. It can be added to containers.
 *
 * @author Niels Janssen
 * @since 2008-07-10
 * @package Form.Elements
 */
class Button extends FormElement {

	function __construct( $name, $type, $value, array $properties = array ( ) ) {
		parent::__construct( $name, array_merge ( array( 'value' => $value, 'type' => $type ), $properties ) );
	}

	public function __toString( ) {
		$html = '';

		foreach ( $this->properties as $key => $property ) {
			if ( substr ( $key, 0, 5 ) == 'html_' ) {
				$html .= ' '.substr ( $key, 5 ).'="'.$property.'"';
			}
		}

		return '
		<button'.( !is_null ( $this->properties['type'] ) ? ( ' type="'.$this->properties['type'].'"' ) : null ).' name="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '"'.$html.'>
			' . $this->value . '
		</button>';
	}
}

?>